SlideShare a Scribd company logo
Class No.28  Data Structures http://ecomputernotes.com
Equivalence Relations A binary relation  over a set S is called an  equivalence relation  if it has following properties Reflexivity: for all element xS, x  x Symmetry: for all elements x and y, x  y if and only if y  x Transitivity: for all elements x, y and z, if x  y and y  z then x  z The relation “is related to” is an equivalence relation over the set of people http://ecomputernotes.com
Equivalence Relations The  relationship is  not  an equivalence relation.  It is reflexive, since x  x,  and transitive, since x  y and y  z  implies x  z,  it is  not symmetric  since x  y does not imply y  x. http://ecomputernotes.com
Equivalence Relations Electrical connectivity, where all connections are by metal wires, is an equivalence relation.  It is clearly reflexive, since any component is connected to itself. It is symmetric because if component  a  is connected to component  b  then  b  must be electrically connected to  a . It is transitive, since if component  a  is connected to component  b  and  b  is connected to  c  then  a  is connected to  c . http://ecomputernotes.com
The Disjoint Sets View An equivalence relation  over a set S can be viewed as a partitioning of S into disjoint sets. Each set of the partition is called an  equivalence class  of  (all elements that are related). http://ecomputernotes.com
The Disjoint Sets View Every member of S appears in exactly one equivalence class. To decide if  a    b , we need only to check whether  a  and  b  are in the same equivalence class. This provides a strategy to solve the equivalence problem. http://ecomputernotes.com
Dynamic Equivalence Problem If the relation is stored as a two-dimensional array of booleans, then, of course, this can be done in constant time.  The problem is that the relation is usually not explicitly defined, but, rather, implicitly defined. Haaris Haaris Saad Ahmed Omar Asim Qasim Saad Ahmed Omar Asim Qasim T T T T T T T T T T http://ecomputernotes.com
Dynamic Equivalence Problem As an example, suppose the equivalence relation is defined over the five-element set { a 1 ,  a 2 ,  a 3 ,  a 4 ,  a 5  }. There are 25 pairs of elements, each of which is related or not. (30 pairs – 5 self-pairs=25). http://ecomputernotes.com
Dynamic Equivalence Problem However, given the information  a 1    a 2 ,  a 3    a 4 , a 5    a 1 , a 4    a 2 , Implies that all pairs are related. We would like to be able to infer this information quickly. a 2 a 3 a 1 a 5 a 4 http://ecomputernotes.com
Dynamic Equivalence Problem The input is initially a collection of  n  sets, each with one element. This initial representation is that all relations (except reflexive relations) are false. Each set has a different element so that  S i    S j  =  ; this makes the sets  disjoint . http://ecomputernotes.com
Dynamic Equivalence Problem There are two permissible operations:  find  and  union . Find  returns the name of the set (equivalence class) that contains a given element, i.e.,  S i   find( a ) Union  merges two sets to create a new set  S k  =  S i    S j . http://ecomputernotes.com
Dynamic Equivalence Problem If we want to add the relation  a    b , then we first see if  a  and  b  are already related. This is done by performing  finds  on both  a  and  b  to check whether they are in the same set. If they are not, we apply  union  which merges the two sets  a  and  b  belong to. The algorithm to do this is frequently known as  Union / Find  for this reason. http://ecomputernotes.com
Dynamic Equivalence Problem Notice that we do not perform any operations comparing the relative values of set elements.  We merely require knowledge of their location, i.e., which set an element belongs to. We can thus assume that all elements are numbered sequentially from 1 to  n . Thus, initially we have  S i  = { i } for  i  = 1 through  n . http://ecomputernotes.com
Dynamic Equivalence Problem Our second observation is that the name of the set returned by find is fairly arbitrary. All that really matters is that  find ( x ) =  find ( y ) if an only if  x  an  y  are in the same set. We will now discuss a solution to the  union / find  problem that for any sequence of at most  m  finds and upto  n -1 unions will require time proportional to ( m + n ). http://ecomputernotes.com

More Related Content

PPTX
Disjoint set / Union Find Data Structure
PPT
A17-1 graphing systems
PPTX
M correlation 1
PPTX
February 11, 2015,
PPTX
Tn 110 lecture 2 logic
PPTX
Matrix Exponential
PPTX
Derivatives
PDF
Determinants3
Disjoint set / Union Find Data Structure
A17-1 graphing systems
M correlation 1
February 11, 2015,
Tn 110 lecture 2 logic
Matrix Exponential
Derivatives
Determinants3

What's hot (16)

PPTX
10th algebra-lesson 1- part 1
DOCX
Cross product
PDF
Pattern recognition 4 - MLE
PPT
Proving Trigonometric Identities
PPTX
Scaling hypothesis
PPT
Pres Scatter Plots (Section 1.5)
PPT
3.1 (8th)
PPT
Calc03 8 (1)
PPT
Stats For Life Module7 Oc
PDF
7.3 Elimination Method
PPTX
Exponents and Radicals (Class 8th)
PDF
CONSISTENCY CRITERIA
PPTX
Advanced functions part ii
PPT
Simplifying radical expressions, rational exponents, radical equations
PPT
Algebra review
10th algebra-lesson 1- part 1
Cross product
Pattern recognition 4 - MLE
Proving Trigonometric Identities
Scaling hypothesis
Pres Scatter Plots (Section 1.5)
3.1 (8th)
Calc03 8 (1)
Stats For Life Module7 Oc
7.3 Elimination Method
Exponents and Radicals (Class 8th)
CONSISTENCY CRITERIA
Advanced functions part ii
Simplifying radical expressions, rational exponents, radical equations
Algebra review
Ad

Viewers also liked (7)

PPT
computer notes - Data Structures - 39
PPT
computer notes - Data Structures - 30
DOC
Computer notes - Including Constraints
PPT
computer notes - Data Structures - 11
PPT
e computer notes - Advanced subqueries
PPT
Computer notes - Analysis of Union
PPTX
Input Output - Computer Architecture
computer notes - Data Structures - 39
computer notes - Data Structures - 30
Computer notes - Including Constraints
computer notes - Data Structures - 11
e computer notes - Advanced subqueries
Computer notes - Analysis of Union
Input Output - Computer Architecture
Ad

Similar to computer notes - Data Structures - 28 (20)

PPT
computer notes - Data Structures - 27
PPT
Top school in delhi
PPTX
Lecture 6 disjoint set
PPTX
Introduction to Posets, Hasse Diagrams, Lattices.pptx
PPTX
The-Set-theory-presentation-by-students.pptx
PPTX
Illustrating system of linear equation.pptx
PDF
BCA_Semester-II-Discrete Mathematics_unit-ii_Relation and ordering
PPTX
Section 9: Equivalence Relations & Cosets
PPTX
Stochastic Processes Homework Help
PDF
Relations and Functions.pdf
PPT
Section3 1
PPTX
Path & application(ds)2
PDF
Mathematical Model of Affinity Predictive Model for Multi-Class Prediction
PDF
PPTX
Ananlyzing Stabiblity of Model Ecosystems
PPTX
Tutorial on EM algorithm – Part 1
PPT
Admission in India 2014
PDF
Graph Matrices and Application: Motivational overview, matrix of graph, relat...
PDF
GRAPH MATRIX APPLICATIONS.pdf
PPT
Data matching.ppt
computer notes - Data Structures - 27
Top school in delhi
Lecture 6 disjoint set
Introduction to Posets, Hasse Diagrams, Lattices.pptx
The-Set-theory-presentation-by-students.pptx
Illustrating system of linear equation.pptx
BCA_Semester-II-Discrete Mathematics_unit-ii_Relation and ordering
Section 9: Equivalence Relations & Cosets
Stochastic Processes Homework Help
Relations and Functions.pdf
Section3 1
Path & application(ds)2
Mathematical Model of Affinity Predictive Model for Multi-Class Prediction
Ananlyzing Stabiblity of Model Ecosystems
Tutorial on EM algorithm – Part 1
Admission in India 2014
Graph Matrices and Application: Motivational overview, matrix of graph, relat...
GRAPH MATRIX APPLICATIONS.pdf
Data matching.ppt

More from ecomputernotes (20)

PPT
computer notes - Data Structures - 20
PPT
computer notes - Data Structures - 15
DOC
Computer notes - Date time Functions
DOC
Computer notes - Subqueries
DOC
Computer notes - Other Database Objects
PPT
computer notes - Data Structures - 19
PPT
computer notes - Data Structures - 31
PPT
computer notes - Data Structures - 4
PPT
computer notes - Data Structures - 13
DOC
Computer notes - Advanced Subqueries
DOC
Computer notes - Aggregating Data Using Group Functions
PPT
computer notes - Data Structures - 16
PPT
computer notes - Data Structures - 22
PPT
computer notes - Data Structures - 35
PPT
computer notes - Data Structures - 36
DOC
Computer notes - Enhancements to the GROUP BY Clause
DOC
Computer notes - Manipulating Data
DOC
Computer notes - Writing Basic SQL SELECT Statements
PPT
computer notes - Data Structures - 14
PPT
computer notes - Data Structures - 10
computer notes - Data Structures - 20
computer notes - Data Structures - 15
Computer notes - Date time Functions
Computer notes - Subqueries
Computer notes - Other Database Objects
computer notes - Data Structures - 19
computer notes - Data Structures - 31
computer notes - Data Structures - 4
computer notes - Data Structures - 13
Computer notes - Advanced Subqueries
Computer notes - Aggregating Data Using Group Functions
computer notes - Data Structures - 16
computer notes - Data Structures - 22
computer notes - Data Structures - 35
computer notes - Data Structures - 36
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Manipulating Data
Computer notes - Writing Basic SQL SELECT Statements
computer notes - Data Structures - 14
computer notes - Data Structures - 10

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Per capita expenditure prediction using model stacking based on satellite ima...
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development

computer notes - Data Structures - 28

  • 1. Class No.28 Data Structures http://ecomputernotes.com
  • 2. Equivalence Relations A binary relation  over a set S is called an equivalence relation if it has following properties Reflexivity: for all element xS, x  x Symmetry: for all elements x and y, x  y if and only if y  x Transitivity: for all elements x, y and z, if x  y and y  z then x  z The relation “is related to” is an equivalence relation over the set of people http://ecomputernotes.com
  • 3. Equivalence Relations The  relationship is not an equivalence relation. It is reflexive, since x  x, and transitive, since x  y and y  z implies x  z, it is not symmetric since x  y does not imply y  x. http://ecomputernotes.com
  • 4. Equivalence Relations Electrical connectivity, where all connections are by metal wires, is an equivalence relation. It is clearly reflexive, since any component is connected to itself. It is symmetric because if component a is connected to component b then b must be electrically connected to a . It is transitive, since if component a is connected to component b and b is connected to c then a is connected to c . http://ecomputernotes.com
  • 5. The Disjoint Sets View An equivalence relation  over a set S can be viewed as a partitioning of S into disjoint sets. Each set of the partition is called an equivalence class of  (all elements that are related). http://ecomputernotes.com
  • 6. The Disjoint Sets View Every member of S appears in exactly one equivalence class. To decide if a  b , we need only to check whether a and b are in the same equivalence class. This provides a strategy to solve the equivalence problem. http://ecomputernotes.com
  • 7. Dynamic Equivalence Problem If the relation is stored as a two-dimensional array of booleans, then, of course, this can be done in constant time. The problem is that the relation is usually not explicitly defined, but, rather, implicitly defined. Haaris Haaris Saad Ahmed Omar Asim Qasim Saad Ahmed Omar Asim Qasim T T T T T T T T T T http://ecomputernotes.com
  • 8. Dynamic Equivalence Problem As an example, suppose the equivalence relation is defined over the five-element set { a 1 , a 2 , a 3 , a 4 , a 5 }. There are 25 pairs of elements, each of which is related or not. (30 pairs – 5 self-pairs=25). http://ecomputernotes.com
  • 9. Dynamic Equivalence Problem However, given the information a 1  a 2 , a 3  a 4 , a 5  a 1 , a 4  a 2 , Implies that all pairs are related. We would like to be able to infer this information quickly. a 2 a 3 a 1 a 5 a 4 http://ecomputernotes.com
  • 10. Dynamic Equivalence Problem The input is initially a collection of n sets, each with one element. This initial representation is that all relations (except reflexive relations) are false. Each set has a different element so that S i  S j =  ; this makes the sets disjoint . http://ecomputernotes.com
  • 11. Dynamic Equivalence Problem There are two permissible operations: find and union . Find returns the name of the set (equivalence class) that contains a given element, i.e., S i  find( a ) Union merges two sets to create a new set S k = S i  S j . http://ecomputernotes.com
  • 12. Dynamic Equivalence Problem If we want to add the relation a  b , then we first see if a and b are already related. This is done by performing finds on both a and b to check whether they are in the same set. If they are not, we apply union which merges the two sets a and b belong to. The algorithm to do this is frequently known as Union / Find for this reason. http://ecomputernotes.com
  • 13. Dynamic Equivalence Problem Notice that we do not perform any operations comparing the relative values of set elements. We merely require knowledge of their location, i.e., which set an element belongs to. We can thus assume that all elements are numbered sequentially from 1 to n . Thus, initially we have S i = { i } for i = 1 through n . http://ecomputernotes.com
  • 14. Dynamic Equivalence Problem Our second observation is that the name of the set returned by find is fairly arbitrary. All that really matters is that find ( x ) = find ( y ) if an only if x an y are in the same set. We will now discuss a solution to the union / find problem that for any sequence of at most m finds and upto n -1 unions will require time proportional to ( m + n ). http://ecomputernotes.com

Editor's Notes

  • #3: End of lecture 33, Start of lecture 34
  • #15: End of lecture 34